<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>


<%--
  Created by IntelliJ IDEA.
  User: yzh
  Date: 2024/12/12
  Time: 20:12
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title></title>
</head>
<body>
<h3 align="center">欢迎登录图书管理系统</h3>
<form action="CheckServlet" method="post">
    <h5 align="center">
        图书名：
        <input align="center" type="text" name="bookname">
        <input align="center" type="submit" value="查找">
        ${error2}
        <a href="/booksystem/addbook.jsp" target="_self">添加图书</a>

    </h5>
    <table align="center" border="1px">
        <tr align="center">
            <td>编号</td>
            <td>书名</td>
            <td>价格</td>
            <td>出版社</td>
            <td>ISBN</td>
            <td>编辑</td>
        </tr>

        <%--<c:forEach标签用于遍历输出数据库的所有数据,每次输出一行数据--%>

<%--        <c:forEach var="books" items="${sessionScope.listBooks}">--%>
<%--            <tr>--%>
<%--                <td>${books.id}</td>--%>
<%--                <td>${books.bookname}</td>--%>
<%--                <td>${books.price}</td>--%>
<%--                <td>${books.address}</td>--%>
<%--                <td>${books.isbn}</td>--%>
<%--                <td>--%>
<%--                    <a href="DeleteServlet?id=${books.id}" target="_self">删除</a>--%>
<%--                    <a href="edit.jsp" target="_self?">修改</a>--%>
<%--                </td>--%>
<%--            </tr>--%>
<%--        </c:forEach>--%>
<%--        <c:forEach var="books" items="${sessionScope.listBooks}">--%>
            <c:forEach var="books" items="${listBooks}">
            <tr>
                <td>${books.id}</td>
                <td>${books.bookname}</td>
                <td>${books.price}</td>
                <td>${books.address}</td>
                <td>${books.isbn}</td>
                <td><a href="DeleteServlet?id=${books.id}" target="_self">删除</a> </td>
<%--                //其实不存在删除失败一说,--%>
<%--                //一般删除失败有条件,像剩余最后一本书,有权限的书等,不会写那种代码,先这样吧.--%>
                <td><a href="edit.jsp" target="_self">修改</a> </td>
            </tr>
        </c:forEach>

        <%--</tr>
        <tr>
            <td>${listBooks.id}</td>
            <td>${listBooks.bookname}</td>
            <td>${listBooks.price}</td>
            <td>${listBooks.address}</td>
            <td>${listBooks.isbn}</td>
            <td>
                <a href="#" target="_blank">删除</a>
                <a href="#" target="_blank">修改</a>
            </td>--%>
    </table>
</form>
<%--<script>--%>
<%--    var errori = '${param.error2}';--%>
<%--    if (errori === 'yes' ) {&lt;%&ndash;errori变量也会导致登录就失败&ndash;%&gt;--%>
<%--        alert("删除失败");--%>
<%--    }--%>
<%--</script>--%>
<script>
    var errori = '${param.error1}'
    if (errori === 'yes') {
        alert("用户名或密码错误");
    }
</script>
<%--response.sendRedirect("refresh", "2;error1=yes");--%>
</body>
</html>
